package com.sm.activities;

import java.util.ArrayList;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;

import com.sm.R;
import com.sm.activities.subscriptionmanager.CoursesManager_Tab;
import com.sm.activities.subscriptionmanager.StudentsManager_Tab;
import com.sm.activities.subscriptionmanager.Tab_Cours_Manager;
import com.sm.bo.Course;
import com.sm.bo.Student;

@SuppressWarnings("deprecation")
public class WelcomeActivity extends TabActivity {

	public static ArrayList<Student> studentsList;
	public static ArrayList<Course> coursesList;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_welcome);
		
		initializeLists();
        addTabs();		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.welcome, menu);
		return true;
	}	

	private void initializeLists(){
		//Initializing students list
		studentsList = new ArrayList<Student>();
		studentsList.add(new Student("Makhlouf", "17 rue du Ruisseau", "5147778888"));
		studentsList.add(new Student("Alain", "3 rue de l'Amour", "5142226666"));
		studentsList.add(new Student("Robert", "1232 Bd. Paradise", "5149994444"));
		studentsList.add(new Student("Alberto", "6125", "5148259237"));
		
		//Initializing courses list
		coursesList = new ArrayList<Course>();
		coursesList.add(new Course("AS1","Physique"));
		coursesList.add(new Course("AS1","Chimie"));
		coursesList.add(new Course("AS2","Math"));
		coursesList.add(new Course("AS2","Informatique de base"));
		coursesList.add(new Course("LL1","Anglais niveau B2"));
	}
	
	private int addCourseToStudent(Course course)
	{
		return 1;
	}
	
	private void addTabs()
	{
		
		TabHost tabHost = getTabHost();

        // Tab for Students
        TabSpec studentsSpec = tabHost.newTabSpec("Students");
        studentsSpec.setIndicator("Students", getResources().getDrawable(R.drawable.icon_photos_tab));
        Intent studentsIntent = new Intent(this, StudentsManager_Tab.class);
        studentsSpec.setContent(studentsIntent);
        
        // Tab for Courses
        TabSpec coursesSpec = tabHost.newTabSpec("Courses");
        // setting Title and Icon for the Tab
        coursesSpec.setIndicator("Courses", getResources().getDrawable(R.drawable.icon_videos_tab));
        Intent coursesIntent = new Intent(this, Tab_Cours_Manager.class);
        coursesSpec.setContent(coursesIntent);
        
        // Adding all TabSpec to TabHost
        tabHost.addTab(studentsSpec); // Adding students tab
        tabHost.addTab(coursesSpec); // Adding courses tab
        }
}
